home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 4 / ads / i-cpp < prev    next >
Text File  |  1996-02-12  |  8KB  |  168 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                       I N T E R F A C E S . C P P                        --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc.     --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- GNAT was originally developed  by the GNAT team at  New York University. --
  25. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  26. --                                                                          --
  27. ------------------------------------------------------------------------------
  28.  
  29. --  Definitions for interfacing to C++ classes
  30.  
  31. with System;
  32. with System.Storage_Elements;
  33.  
  34. package Interfaces.CPP is
  35.  
  36.    package S   renames System;
  37.    package SSE renames System.Storage_Elements;
  38.  
  39.    --  This package corresponds to Ada.Tags but applied to tagged types
  40.    --  which are 'imported' from C++ and correspond to exactly to a C++
  41.    --  Class.  GNAT doesn't know about the structure od the C++ dispatch
  42.    --  table (Vtable) but always access it through the procedural interface
  43.    --  defined below, thus the implementation of this package (the body) can
  44.    --  be customized to another C++ compiler without any change in the
  45.    --  compiler code itself as long as this procedural interface is
  46.    --  respected. Note that Ada.Tags defines a very similar procedural
  47.    --  interface to the regular Ada Dispatch Table.
  48.  
  49.    type Vtable_Ptr is private;
  50.  
  51.    function Expanded_Name (T : Vtable_Ptr) return String;
  52.    function External_Tag  (T : Vtable_Ptr) return String;
  53.  
  54. private
  55.  
  56.    procedure CPP_Set_Prim_Op_Address
  57.      (T        : Vtable_Ptr;
  58.       Position : Positive;
  59.       Value    : S.Address);
  60.    --  Given a pointer to a dispatch Table (T) and a position in the
  61.    --  dispatch Table put the address of the virtual function in it
  62.    --  (used for overriding)
  63.  
  64.    function CPP_Get_Prim_Op_Address
  65.      (T        : Vtable_Ptr;
  66.       Position : Positive)
  67.       return     S.Address;
  68.    --  Given a pointer to a dispatch Table (T) and a position in the DT
  69.    --  this function returns the address of the virtual function stored
  70.    --  in it (used for dispatching calls)
  71.  
  72.    procedure CPP_Set_Inheritance_Depth
  73.      (T     : Vtable_Ptr;
  74.       Value : Natural);
  75.    --  Given a pointer to a dispatch Table, stores the value representing
  76.    --  the depth in the inheritance tree. Used during elaboration of the
  77.    --  tagged type.
  78.  
  79.    function CPP_Get_Inheritance_Depth (T : Vtable_Ptr) return Natural;
  80.    --  Given a pointer to a dispatch Table, retreives the value representing
  81.    --  the depth in the inheritance tree. Used for membership.
  82.  
  83.    procedure CPP_Set_TSD (T : Vtable_Ptr; Value : S.Address);
  84.    --  Given a pointer T to a dispatch Table, stores the address of the
  85.    --  record containing the Type Specific Data generated by GNAT
  86.  
  87.    function CPP_Get_TSD (T : Vtable_Ptr) return S.Address;
  88.    --  Given a pointer T to a dispatch Table, retreives the address of the
  89.    --  record containing the Type Specific Data generated by GNAT
  90.  
  91.    CPP_DT_Prologue_Size  : constant SSE.Storage_Count :=
  92.                              2 * (Standard'Address_Size / S.Storage_Unit);
  93.    --  Size of the first part of the dispatch table
  94.  
  95.    CPP_DT_Entry_Size     : constant SSE.Storage_Count :=
  96.                              2 * (Standard'Address_Size / S.Storage_Unit);
  97.    --  Size of each primitive operation entry in the Dispatch Table.
  98.  
  99.    CPP_TSD_Prologue_Size : constant SSE.Storage_Count :=
  100.                              4 * (Standard'Address_Size / S.Storage_Unit);
  101.    --  Size of the first part of the type specific data
  102.  
  103.    CPP_TSD_Entry_Size    : constant SSE.Storage_Count :=
  104.                              Standard'Address_Size / S.Storage_Unit;
  105.    --  Size of each ancestor tag entry in the TSD
  106.  
  107.    procedure CPP_Inherit_DT
  108.     (Old_T       : Vtable_Ptr;
  109.      New_T       : Vtable_Ptr;
  110.      Entry_Count : Natural);
  111.    --  Entry point used to initialize the DT of a type knowing the
  112.    --  tag of the direct ancestor and the number of primitive ops that are
  113.    --  inherited (Entry_Count).
  114.  
  115.    procedure CPP_Inherit_TSD
  116.      (Old_TSD : S.Address;
  117.       New_Tag : Vtable_Ptr);
  118.    --  Entry point used to initialize the TSD of a type knowing the
  119.    --  TSD of the direct ancestor.
  120.  
  121.    function CPP_CW_Membership (Obj_Tag, Typ_Tag : Vtable_Ptr) return Boolean;
  122.    --  Given the tag of an object and the tag associated to a type, return
  123.    --  true if Obj is in Typ'Class.
  124.  
  125.    procedure CPP_Set_External_Tag (T : Vtable_Ptr; Value : S.Address);
  126.    --  set the address of the string containing the external tag
  127.    --  in the Dispatch table
  128.  
  129.    function CPP_Get_External_Tag (T : Vtable_Ptr) return S.Address;
  130.    --  retreive the address of a null terminated string containing
  131.    --  the external name
  132.  
  133.    procedure CPP_Set_Expanded_Name (T : Vtable_Ptr; Value : S.Address);
  134.    --  set the address of the string containing the expanded name
  135.    --  in the Dispatch table
  136.  
  137.    function CPP_Get_Expanded_Name (T : Vtable_Ptr) return S.Address;
  138.    --  retreive the address of a null terminated string containing
  139.    --  the expanded name
  140.  
  141.    function Displaced_This
  142.     (Current_This : S.Address;
  143.      Vptr         : Vtable_Ptr;
  144.      Position     : Positive)
  145.      return         S.Address;
  146.    --  Compute the displacement on the "this" pointer in order to be
  147.    --  compatible with MI.
  148.    --  (used for virtual function calls)
  149.  
  150.    type Vtable;
  151.    type Vtable_Ptr is access all Vtable;
  152.  
  153.    pragma Inline (CPP_Set_Prim_Op_Address);
  154.    pragma Inline (CPP_Get_Prim_Op_Address);
  155.    pragma Inline (CPP_Set_Inheritance_Depth);
  156.    pragma Inline (CPP_Get_Inheritance_Depth);
  157.    pragma Inline (CPP_Set_TSD);
  158.    pragma Inline (CPP_Get_TSD);
  159.    pragma Inline (CPP_Inherit_DT);
  160.    pragma Inline (CPP_CW_Membership);
  161.    pragma Inline (CPP_Set_External_Tag);
  162.    pragma Inline (CPP_Get_External_Tag);
  163.    pragma Inline (CPP_Set_Expanded_Name);
  164.    pragma Inline (CPP_Get_Expanded_Name);
  165.    pragma Inline (Displaced_This);
  166.  
  167. end Interfaces.CPP;
  168.